<template>
  <!-- 提示框组件 -->
  <!-- 
      success    icon-toast_chenggong
      warning    icon-toast-jinggao
      danger    icon-toast-shibai_huaban
   -->
  <div class="toast">
    <i
      :class="
        type == 'success'
          ? 'iconfont icon-toast_chenggong'
          : type == 'warning'
          ? 'iconfont icon-toast-jinggao'
          : 'iconfont icon-toast-shibai_huaban'
      "
    ></i>
    <span>{{ msg }}</span>
  </div>
</template>

<script>
import { mapState } from "vuex";
export default {
  data() {
    return {};
  },
  computed: {
    ...mapState({
      msg: (state) => state.showToast.msg,
      type: (state) => state.showToast.type,
    }),
  },
};
</script>
 
<style lang = "less" scoped>
.toast {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  background-color: #fff;
  padding: 10px 20px;
  border-radius: 6px;
  box-shadow: 0 0 10px #fff;
  i {
    margin-right: 10px;
  }
  .icon-toast_chenggong {
    color: green;
  }
  .icon-toast-jinggao {
    color: orange;
  }
  .icon-toast-shibai_huaban {
    color: red;
  }
}
</style>